/**
 * Created by zhang on 2015/10/30.
 */
var myArr = new Array();
console.log(myArr.prototype);
var empty = [];
var numberArr = ['zreo','one','two','three'];

//numberArr.unshift('T');
numberArr['0'] = 'T';
numberArr.push('four');

//delete numberArr[0];
//numberArr.splice(2,2);

var i;
for (i=0;i<numberArr.length;i+=1)
{
    document.write(numberArr[i]+'<br />');
}

console.log(numberArr);
console.log(typeof numberArr);
console.log(numberArr.length);

//var numberObj = {'0':'zero','1':'one','2':'two','3':'three'};
//console.log(typeof numberObj);

/**
 * @param value
 * @returns {*|boolean}
 */
var is_array = function(value)
{
    return value &&
            typeof  value === 'object' &&
            value.constructor === Array;
};
//alert(is_array(numberArr));

/**
 * @param value
 * @returns {boolean}
 */
var is_array = function(value)
{
    return Object.prototype.toString.apply(value) === '[object Array]';
}
//扩展 数组方法
Array.prototype.reduce = function(f,value)
{
    var i;
    for(i=0;i<this.length;i+=1)
    {
        value = f(this[i],value);
    }
    return value;
};


//Array.method('reduce',function(f,value){
//    var i;
//    for(i=0;i<this.length;i+=1)
//    {
//        value = f(this[i],value);
//    }
//    return value;
//});


var data = [1,3,4,5,7,9];
var add = function(a,b)
{
    return a+b;
};
var mult = function(a,b)
{
    return a*b;
};
var sum = data.reduce(add,1);
alert(sum);

//var array = array();

//array.concat();
//array.join();
//
//array.pop();
//array.shift();
//array.push(); //footer
//array.unshift(); //header
//
//array.reverse();
//array.sort();
//array.slice(); //copy
//array.splice(); //delete






